package managers;

import structures.AD;
import structures.ADsList;
import structures.FeedbackInsertionOutcome;
import structures.GamifyResult;
import structures.Product;
import structures.ProductList;
import structures.Seller;
import structures.User;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;


public class JsonManager {

	public String generateJSON(Object object) {
		String jsonAnswer;
		Gson gson;
		gson =  new GsonBuilder().setPrettyPrinting().create(); 
		jsonAnswer =gson.toJson(object);
		return jsonAnswer;
	}
	
	
	public User toUser(String json){
		Gson gson;
		gson =  new GsonBuilder().create();
		return gson.fromJson(json, User.class);
	}
	
	public AD toAD(String json){
		Gson gson;
		gson =  new GsonBuilder().create();
		return gson.fromJson(json, AD.class);
	}


	public ADsList toADsList(String json) {
		Gson gson;
		gson =  new GsonBuilder().create();
		return gson.fromJson(json, ADsList.class);
	}


	public GamifyResult toGamifyResult(String json) {
		Gson gson;
		gson =  new GsonBuilder().create();
		return gson.fromJson(json, GamifyResult.class);
	}


	public Seller toSeller(String json) {
		Gson gson;
		gson =  new GsonBuilder().create();
		return gson.fromJson(json, Seller.class);
	}
	
	public FeedbackInsertionOutcome toFeedbackInsertionOutcome(String json) {
		Gson gson;
		gson =  new GsonBuilder().create();
		return gson.fromJson(json, FeedbackInsertionOutcome.class);
	}
	
	public ProductList toProductList(String json) {
		Gson gson;
		gson = new GsonBuilder().create();
		return gson.fromJson(json, ProductList.class);
	}
	
	public Product toProduct(String json) {
		Gson gson;
		gson = new GsonBuilder().create();
		return gson.fromJson(json, Product.class);
	}

}
